#include "../log/lcllog.h"

void LoggerTest(const std::string& loggername)
{
    // 直接通过getLogger获取
    // lcllog::LoggerManager::getInstance().getLogger(loggername)
    lcllog::Logger::ptr lp = lcllog::getLogger(loggername);
    lp->debug("%s:%d", "debug", 1);
    lp->info("%s:%d", "info", 1);
    lp->warn("%s:%d", "warn", 1);
    lp->error("%s:%d", "error", 1);
    lp->fatal("%s:%d", "fatal", 1);

    LOG_DEBUG(lp, "%s:%d", "LOG_DEBUG", 2);
    LOG_INFO(lp, "%s:%d", "LOG_INFO", 2);
    LOG_WARN(lp, "%s:%d", "LOG_WARN", 2);
    LOG_ERROR(lp, "%s:%d", "LOG_ERROR", 2);
    LOG_FATAL(lp, "%s:%d", "LOG_FATAL", 2);
}
int main()
{
    // 创建全局的日志器，加入到LoggerManager中，可直接通过LoggerManager获取到日志器
    std::unique_ptr<lcllog::LoggerBuilder> builder(new lcllog::GlobalLoggerBuilder());
    builder->buildLoggerName("lcl-logger");
    builder->buildLoggerLimitLevel(lcllog::LogLevel::value::WARN);
    builder->buildFormatter("[%c][%L][%f:%l]%m%n");
    // builder->buildOut<lcllog::FileOut>("./logfile/test.log");
    builder->buildOut<lcllog::StdoutOut>();
    builder->build();
    LoggerTest("lcl-logger");
    return 0;
}